<template>
    <view class="component-container">
        <no-data v-if="!this.dataList || this.dataList.length == 0" noDatatext="抱歉,没有您想要的商品~"></no-data>
        <!-- 列表 -->
        <view class="brand-list pb120 mt30" v-else>
            <view class="brand-list-item" :class="index % 2 === 0 ? 'even-row' : 'odd-row'"
                v-for="(item, index) in dataList" :key="index">
                <view class="title uni-ellipsis-2">{{ item.title }}</view>
                <view class="model-price">
                    <view class="market-price"> {{ item.marketPrice }}</view>
                    <view class="guide-price"> 指导价{{ item.guidePrice }}万起</view>
                </view>
                <view class="right">
                    <uni-icons type="more-filled" color="#333" size="20" @click="goToDetail(item)"></uni-icons>
                </view>
            </view>
            <view v-show="isLoadMore">
                <uni-load-more :status="loadStatus"></uni-load-more>
            </view>
        </view>
    </view>
</template>
<script>
export default {
    // shared:表示页面 wxss 样式将影响到自定义组件
    options: {
        styleIsolation: 'shared'
    },
    props: {
        // 当前选中内容区域的下标
        activeIndex: {
            type: Number,
            default: 0
        }
    },
    data() {
        return {
            dataList: [],
            queryParams: {
                pageNum: 1,
                pageSize: 7,
            },
            loadStatus: "loading",
            isLoadMore: false,
        }
    },
    onLoad(options) { },
    onShow() {
        this.dataList = [];
        this.queryParams.pageNum = 1
        this.queryParams.pageSize = 7
        this.getList()
    },
    onReachBottom() {
        if (!this.isLoadMore) {
            this.queryParams.pageNum += 1;
            this.isLoadMore = true;
            this.getList();
        }
    },
    // 下拉刷新
    onPullDownRefresh() {
        this.dataList = [];
        this.queryParams.pageNum = 1
        this.queryParams.pageSize = 7
        this.getList();
        uni.stopPullDownRefresh();
    },
    mounted() {
        this.dataList = [];
        this.queryParams.pageNum = 1
        this.queryParams.pageSize = 7
        this.getList()
    },
    methods: {
        getList() {
            this.dataList = [
                {
                    title: '2024款Panamera 2.9T双涡轮增压国VI2024款Panamera2.9T 双涡轮增压国VI2024款Panamera2.9T双涡轮增压国VI2024款Panamera 2.9T 双涡轮增压国很好',
                    marketPrice: '103.80',
                    guidePrice: '103.80',
                },
                {
                    title: '2024款 Panamera 2.9T行政加长版',
                    marketPrice: '403.80',
                    guidePrice: '403.80',
                },
                {
                    title: '2024款 Panamera 2.9T行政加长版',
                    marketPrice: '403.80',
                    guidePrice: '403.80',
                }, {
                    title: '2024款 Panamera 2.9T行政加长版',
                    marketPrice: '403.80',
                    guidePrice: '403.80',
                }, {
                    title: '2024款 Panamera 2.9T行政加长版',
                    marketPrice: '403.80',
                    guidePrice: '403.80',
                }, {
                    title: '2024款 Panamera 2.9T行政加长版',
                    marketPrice: '403.80',
                    guidePrice: '403.80',
                }, {
                    title: '2024款 Panamera 2.9T行政加长版',
                    marketPrice: '403.80',
                    guidePrice: '403.80',
                }, {
                    title: '2022款 Panamera 2.9T行政加长版',
                    marketPrice: '103.80',
                    guidePrice: '103.80',
                }, {
                    title: '2024款 Panamera 2.9T行政加长版',
                    marketPrice: '403.80',
                    guidePrice: '403.80',
                }, {
                    title: '2024款 Panamera 2.9T行政加长版',
                    marketPrice: '403.80',
                    guidePrice: '403.80',
                }, {
                    title: '2024款 Panamera 2.9T行政加长版',
                    marketPrice: '403.80',
                    guidePrice: '403.80',
                }, {
                    title: '2022款 Panamera 2.9T行政加长版',
                    marketPrice: '103.80',
                    guidePrice: '103.80',
                },
            ]
            // uni.showLoading({ title: "加载中" });
            // list数据，联调时把这里放开
            // let params = {
            //   pageNum: this.queryParams.pageNum,
            //   pageSize: this.queryParams.pageSize,
            // };
            // listUseSeal(params).then((response) => {
            // 	uni.hideLoading();
            // 	this.dataList = [...this.dataList, ...response.rows];
            // 	if (response.rows.length < this.queryParams.pageSize) {
            // 		this.isLoadMore = true;
            // 		this.loadStatus = "nomore";
            // 	} else {
            // 		this.isLoadMore = false;
            // 	}
            // })
            // .catch((err) => {
            // 	console.log(err);
            // });
        },
        goToDetail(item) {
            this.$tab.navigateTo(`/pages/parameter/index`);
        },
    }
}
</script>

<style lang="scss" scoped>
.component-container {
    position: relative;
    display: block;
    padding: 0 24rpx;
}
</style>